package dao.impl;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import org.springframework.stereotype.Repository;

import pojo.Categories;
import dao.CategoriesDao;

@Repository(value="categoriesDao")
public class CategoriesDaoImpl implements CategoriesDao{
	@PersistenceContext(name="un")
	private EntityManager manager;
	
	@Override
	public List<Categories> findAll() {
		List<Categories> categoriesList = manager.createQuery("select c from Categories c").getResultList();
		return categoriesList;
	}

	@Override
	public Categories findById(String id) {
		Categories categories = manager.find(Categories.class, id);
		return categories;
	}
}
